package com.wits.qso.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.wits.platform.service.BaseService;
import com.wits.qso.dao.MaterialdDao;
import com.wits.qso.entity.Course;
import com.wits.qso.entity.MaterialD;

@Component
public class MaterialdService extends BaseService<MaterialD, String>
{
	
	private MaterialdDao materialdDao;

	@Autowired
	public void setMaterialdDao(MaterialdDao materialdDao) {
		this.baseDao = materialdDao;
		this.materialdDao = materialdDao;
	}
	
	public MaterialD findDetail(String materialHId) {
		return materialdDao.findByMaterialHId( materialHId );
	}
	
	public List<MaterialD> findByCourse(Course course) {
		return materialdDao.findByCourse( course );
	}
	
	public int deleteById(String id) {
		return materialdDao.deleteById( id );
	}
	
	public boolean isExisted(String materialHId) {
		boolean result = true;
		
		try {
			findDetail( materialHId );
		} catch (Throwable cause) {
			result = false;
		}
		
		return result;
	}
}
